<?php

// 管理员请求接口
namespace app\admin\controller;


use app\common\controller\Article;
use app\common\controller\Message;
use think\Request;

class AdminRequest
{

//    发布文章
    public function pushArticle(){
        $request = new Request();
        $article = new Article();
        return  $article->insertArticle($request->post('article_name'),
            $request->post('article_content'),
            $request->post('article_content_text'),
            $request->post('article_class'));
    }

//    删除文章
    public function delArticle($articleId){
        $article = new Article();
        return $article->SoftDelArticleById($articleId);
    }

//    更新文章
        public function changeArticle($articleId){
            $request = new Request();
            $article = new Article();
            return  $article->updateArticle($articleId,$request->post('article_name'),
                $request->post('article_content'),
                $request->post('article_content_text'),
                $request->post('article_class'));
        }

//       审核通过 msg
        public function passMsg($msgId){
            $message = new Message();
            return $message->updateMessageById($msgId);
        }

//       删除 msg
    public function delMsg($msgId){
        $message = new Message();
        return $message->softDelMsgById($msgId);
    }

//    修改密码
    public  function  updatePass(){
        $request = new Request();
        $admin = new Admin();
        if($request->post('oldPass') != $admin->selectPassword('admin')['admin_password']){
            return 0;
        }else{
            return $admin->updatePass($request->post('newPass1'));
        }
    }

}